package com.taotao.portal.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbContent;
import com.taotao.rest.webservice.ContentWebService;
import com.taotao.rest.webservice.ContentWebService_Service;
import com.taotao.utils.JsonUtils;

@Service
public class ContentServiceImpl implements ContentService {

	@Override
	public String getContent(long categoryId) {
		// TODO Auto-generated method stub
		ContentWebService_Service factory = new ContentWebService_Service();
		ContentWebService contentWebService = factory.getContentWebServiceImplPort();
		List<TbContent> contentList = contentWebService.getContentList(categoryId);
		
		try {
			
			List<Map> resultList = new ArrayList<>();
			for(TbContent content : contentList) {
				Map map = new HashMap();
				map.put("src", content.getPic());
				map.put("height", 240);
				map.put("width", 670);
				map.put("srcB", content.getPic2());
				map.put("href", content.getUrl());
				map.put("widthB", 550);
				map.put("heightB", 240);
				map.put("alt", content.getTitle());
				resultList.add(map);
			}
			return JsonUtils.objectToJson(resultList);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

}
